#-*- coding: utf-8 -*-
'''
Created on Aug 27, 2012

@author: bbg
'''

from sqlalchemy import Integer, Column, String, MetaData, Table
from sqlalchemy.orm import mapper
    
class ConfigRoom(object):

    _Mapper_ = None
    _company_id_ = -1
    _shop_id_ = -1
    def __init__(self):
        self.id = 0
        self.alias_id = ''
        self.name = ''
        self.floor_id = 0
        self.status = 0
        self.price_type = 0
        self.rank_id = 0
        
    @staticmethod
    def doMapping(company_id, shop_id):
        if ConfigRoom._company_id_ == company_id and ConfigRoom._shop_id_ == shop_id:
            return
        
        if ConfigRoom._Mapper_ is not None:
            ConfigRoom._Mapper_.dispose()
                  
        metaData = MetaData()
        configRoomTable = Table('config_room', metaData,
                           Column('id', Integer, primary_key = True),
                           Column('alias_id', String),
                           Column('name', String),
                           Column('floor_id', Integer),
                           Column('status', Integer),
                           Column('price_type', Integer),
                           Column('rank_id', Integer),
                           schema="shop_%s_%s" % (company_id, shop_id))
        
        ConfigRoom._Mapper_ = mapper(ConfigRoom, configRoomTable)
    